$(function(){
    if(typeof(localStorage.ss)!=="undefined"){
        getss();
    }else{
        var div = $("<div style='text-align: center;'>请输入你想要搜索的关键词！</div>").appendTo(".ssconent");
    }

    $("#ssbtn").click(function () {
        $(".ssconent").children().remove();
        $.ajax({
            url:"front/search/doSearch.do?content="+$(".ssk").val(),
            type:"POST",
            dataType:"JSON",
            success:function (json) {
                if (json.code==0){
                    $(json.data.articleVOs).each(function (i,o) {
                        var div = $("<a href='front/article/articleDetail/"+o.articleId+".do?articleType="+o.articleType+"'><div class='sscrad'><div class='sscrad-title'>"+o.articleName+"</div><div class='sscrad-data'>"+o.releaseTimeStr+"</div></div></a>").appendTo(".ssconent");
                    })
                }else{
                    var div = $("<div style='text-align: center;'>"+json.message+"</div>").appendTo(".ssconent");
                }
            }
        })
    })

})

function getss() {
$(".ssconent").children().remove();
    $.ajax({
        url:"front/search/doSearch.do?content="+localStorage.ss,
        type:"POST",
        dataType:"JSON",
        success:function (json) {
            if (json.code==0){
                $(json.data.articleVOs).each(function (i,o) {
                    var div = $("<a href='front/article/articleDetail/"+o.articleId+".do?articleType="+o.articleType+"'><div class='sscrad'><div class='sscrad-title'>"+o.articleName+"</div><div class='sscrad-data'>"+o.releaseTimeStr+"</div></div></a>").appendTo(".ssconent");
                })
            }else{
                var div = $("<div style='text-align: center;'>"+json.message+"</div>").appendTo(".ssconent");
            }
        }
    })
    localStorage.removeItem('ss');
}

function GetQueryString(name)
{
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return null;
}